package com.xdap.common.utils;

import org.apache.commons.lang3.time.DateFormatUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class InitDateFormatUtil {
    private static final String DATE_FORMAT_YYYY_MM_DD_HH_MI_SS = "yyyy-MM-dd HH:mm:ss";
    private static final String DATE_FORMAT_YYYYMMDDHHMISS = "yyyyMMddHHmmss";


    /**
     * @Description: (获得当前时间类型 ： yyyy - mm - dd hh24 : mi : ss)
     * @author 李淑淑
     * @date 2021/5/17 3:34 下午
     */
    public static String getCurrentYyyyMmDdHhMiSsCc() {
        return DateFormatUtils.format(new Date(), DATE_FORMAT_YYYY_MM_DD_HH_MI_SS);
    }
    public static String getCurrentYyyyMmDdHhMiSs() {
        return DateFormatUtils.format(new Date(), DATE_FORMAT_YYYYMMDDHHMISS);
    }


    public static String getCurrentYyyyMmDdHhMiSsCc(Date dd) {
        return DateFormatUtils.format(dd, DATE_FORMAT_YYYY_MM_DD_HH_MI_SS);
    }
    public static Date toDate(String dd) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT_YYYY_MM_DD_HH_MI_SS);
        Date d = null;
        try {
            d = simpleDateFormat.parse(dd);
        } catch (ParseException e) {
            return null;
        }
        return d;
    }

}
